package com.print;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import javax.swing.JApplet;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.codehaus.jackson.map.ObjectMapper;

import com.model.fx.PrintFX016;
import com.model.fx.PrintFX017;
import com.model.fx.PrintFXLL;
import com.model.fx.PrintFXSK;
import com.model.fx.PrintFXYZ;
import com.sun.xml.internal.fastinfoset.stax.events.Util;
import com.util.JackUtil;
/**
 * 客户端标签打印
 * 
 * @author 
 * 
 */
public class LabelAppletComm extends JApplet {

	private static final long serialVersionUID = -6391368515081034834L;

	public void PrintBJ(final String name,final String boxID,final String customer_name,final String modelName,final String pnlCnt,final String shtCnt,final String totalCnt,final String material,final String date,final String productSpec,final String lotNo,final String jsonAry,final String productCate) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		try {
			ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		Label label = new Label(100, 100, 300);
		label.addRectangle(new Rectangle(1, 1, 98, 97, 0.2));
		label.addText(new Text(8.8, 6.1, "宋体", 0, 18, name));
		label.addText(new Text(72.8, 6.1, "Arial", 0, 13, "ROHS"));
		label.addText(new Text(8.8, 11.1, "宋体", 0, 13, "Client Name: "
				+ customer_name));
		label.addText(new Text(8.8, 15.6, "Arial", 0, 13, "Model:  "
				+ modelName));
		label.addText(new Text(56.2, 15.6, "Arial", 0, 13, "Q'TY(Q) :"
				+ shtCnt));
		label.addText(new Text(8.8, 20.1, "宋体", 0, 13, "Material:  "
				+ material));
		label.addText(new Text(56.2, 20.1, "Arial", 0, 13, "Q'TY(S) :"
				+ totalCnt));
		label.addText(new Text(8.8, 24.6, "Arial", 0, 13, "Date:  "
				+ date));
		label.addText(new Text(56.2, 24.6, "Arial", 0, 13, "Lot No  :"
				+ lotNo));
		label.addText(new Text(8.8, 29.1, "Arial", 0, 13, "Size:  "
				+ productSpec));
		label.addText(new Text(56.2, 29.1, "宋体", 0, 13, "Product Cate:"
				+ productCate));
		label.addText(new Text(8.8, 33.6, "Arial", 0, 13, "Order No:  "));
		Text text = new Text(8.8, 37.6, "Arial Black", 0, 15, boxID);
		label.addText(text);
		Code code = new Code(8.8, 38.8, 9, 0.25, boxID);
		
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (ja == null) {
			System.out.println("Sheet array is empty");
		} else {
			double x1 = 8.8;
			double x2 = 38.8;
			double x3 = 68.8;
			double y = 51.1;
			double step = 3.5;
			for (int i = 0; i < ja.length; i++) {
				double x = 0;
				if (i % 3 == 0) {
					x = x1;
				} else if ( i % 3 == 1){
					x = x2;
				}else{
					x = x3;
				}
				double _y =  y + (i/3)*step;
				label.addText(new Text(x, _y, "Arial", 0, 12, ja[i]));
			}
		}
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	public void PrintJDF(final String name,final String boxID,final String customer_name,final String modelName,final String pnlCnt,final String shtCnt,final String totalCnt,
						final String date,final String productSpec,final String lotNo,final String jsonAry,final String productCate) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		try {
			ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		Label label = new Label(100, 100, 300);
		label.addRectangle(new Rectangle(1, 1, 98, 97, 0.2));
		label.addText(new Text(5.8, 6.1, "宋体", 0, 18, name));
		label.addText(new Text(72.8, 6.1, "Arial", 0, 13, "ROHS"));
		label.addText(new Text(5.8, 10.1, "宋体", 0, 13, "Client Name: "
				+ customer_name));
		label.addText(new Text(5.8, 13.6, "Arial", 0, 13, "Model:  "
				+ modelName));
		label.addText(new Text(53.2, 13.6, "Arial", 0, 13, "Q'TY(Q) :"
				+ shtCnt));
		label.addText(new Text(5.8, 17.1, "Arial", 0, 13, "Date:  "
				+ date));
		label.addText(new Text(53.2, 17.1, "Arial", 0, 13, "Q'TY(S) :"
				+ totalCnt));
		label.addText(new Text(5.8, 20.6, "Arial", 0, 13, "Size:  "
				+ productSpec));
		label.addText(new Text(53.2, 20.6, "Arial", 0, 13, "Lot No  :"
				+ lotNo));
		label.addText(new Text(5.8, 23.9, "Arial", 0, 13, "Order No:  "));
		label.addText(new Text(53.2, 23.9, "宋体", 0, 13, "Product Cate:"
				+ productCate));
		Text text = new Text(5.8, 27.5, "Arial Black", 0, 15, boxID);
		label.addText(text);
		Code code = new Code(5.8, 28.5, 8, 0.25, boxID);
		
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (ja == null) {
			System.out.println("Sheet array is empty");
		} else {
			double x1 = 5.8;
			double x2 = 36.8;
			double x3 = 67.8;
			double y = 39.8;
			double step = 3.5;
			for (int i = 0; i < ja.length; i++) {
				double x = 0;
				if (i % 3 == 0) {
					x = x1;
				} else if ( i % 3 == 1){
					x = x2;
				}else{
					x = x3;
				}
				double _y =  y + (i/3)*step;
				label.addText(new Text(x, _y, "Arial", 0, 12, ja[i]));
			}
		}
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	public void PrintPlt(final String name,final String pallet_id,final String customer_name,final String model_name, 
							final String date,final String pnl_qty,final String totalCnt){
		
		Label label = new Label(100, 100, 300);
		label.addRectangle(new Rectangle(1, 1, 98, 98, 0.2));
		label.addText(new Text(8.8, 6.1, "宋体", 0, 18, name));
		label.addText(new Text(72.8, 6.1, "Arial", 0, 13, "ROHS"));
		label.addText(new Text(8.8, 13.1, "宋体", 0, 13, "Client Name: "
				+ customer_name));
		label.addText(new Text(8.8, 20.6, "Arial", 0, 13, "Model:  "
				+ model_name));
		label.addText(new Text(8.8, 27.6, "Arial", 0, 13, "QTY:  "
				+ pnl_qty));
		label.addText(new Text(8.8, 34.6, "Arial", 0, 13, "Total QTY:  "
				+ totalCnt));
		label.addText(new Text(8.8, 41.6, "Arial", 0, 13, "PACK DATE:  "
				+ date));
		label.addText(new Text(8.8, 48.6, "Arial", 0, 13, "PALLET:  "
				+ pallet_id));
		Code code = new Code(8.8, 50.6, 9, 0.25, pallet_id);
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	public void PrintJX4BS(final String customer_id,final String mode_id,final String date,final String prd_spec,
			final String wo_id,final String woCnt,final String jsonCntAry,final String boxRule,final String totalCnt,
			final String jsonAry,final String layout_cnt,final String mtrl_id,final String habk_id) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		String[]jaCnt = null;
		int loopCnt;
		int li;
		int index;
		try {
			ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		try {
			jaCnt = mapper.readValue(jsonCntAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		System.out.println("Start");
		double len = ja.length;
		System.out.println(len);
		
		loopCnt = (int)Math.ceil(len/12);
		System.out.println(Math.ceil(len/12));
		System.out.println(len/12);
		System.out.println(loopCnt);
		
		for(li=0;li<loopCnt;li++){
			LabelJX label = new LabelJX(212, 290, 300);
			int j=0;
			int k=0;
			int lj=0;
			double step = 5.3;
			double _y = 6.5;
			double _yy = 13.7;
			double Max_y=72.5;
			for(lj=0;lj<12;lj++){
				index = li*12+lj;
				if( index >= ja.length){
					break;
				}
				j = lj%3;
				/**
				 * 横坐标值
				 */
				double x1 = 3.8 + 69*j;
				double x2 = 30.8 + 69*j;
				double x3 = 2 + 69*j;
				double x4 = 23 + 69*j;
				double x6 = 29.8 + 69*j;
				/**
				 * 纵坐标值
				 */
				k = lj/3;
				double y1= 8 + k*Max_y ;
				double y2 = 6.8 + k*Max_y ;
				double y3 = _y + Max_y*k + step;
				double y4 = _y + Max_y*k + 2*step;
				double y5 = _y + Max_y*k + 3*step;
				double y6 = _y + Max_y*k + 4*step;
				double y7 = _y + Max_y*k + 5*step;
				double y8 = _y + Max_y*k + 6*step;
				double y9 = _y + Max_y*k + 7*step;
				double ya = _y + Max_y*k + 8*step;
				double yb = _y + Max_y*k + 9*step;
				double yA = _y + Max_y*k + 10*step;
				double yB = 5.3  + k*Max_y;
				double yC = 62.7 + k*Max_y;
				/**
				 * Line的纵坐标值
				 */
				double _yy1 = _yy + k*Max_y ;
				double _yy2 = _yy + k*Max_y + step;
				double _yy3 = _yy + k*Max_y + 2*step;
				double _yy4 = _yy + k*Max_y + 3*step;
				double _yy5 = _yy + k*Max_y + 4*step;
				double _yy6 = _yy + k*Max_y + 5*step;
				double _yy7 = _yy + k*Max_y + 6*step;
				double _yy8 = _yy + k*Max_y + 7*step;
				double _yy9 = _yy + k*Max_y + 8*step;
				double _yy0 = _yy + k*Max_y + 9*step;
				
				label.addRectangle(new Rectangle(x3, y1, 67, 64.2, 0.2));
				label.addLine(new Line(x4,y1,53.6,0.2,-90));
				
				label.addText(new Text(x1, yB, "宋体", 2, 14, "方兴科技"));
//				label.addText(new Text(x5, y2, "宋体", 0, 10, "沃格光电"));
				label.addText(new Text(x6, y2, "宋体", 0, 14, "原料来料标签"));
				
				label.addText(new Text(x1, y3, "宋体", 0, 12, "客户代码"));
				label.addText(new Text(x2, y3, "Arial", 0, 12, customer_id));
				label.addLine(new Line(x3,_yy1,67,0.2,0));
				
				label.addText(new Text(x1, y4, "宋体", 0, 12, "客户型号"));
				label.addText(new Text(x2, y4, "宋体", 0, 12, mode_id+"("+layout_cnt+"模)"));
				label.addLine(new Line(x3,_yy2,67,0.2,0));
				
				label.addText(new Text(x1, y5, "宋体", 0, 12, "料号"));
				label.addText(new Text(x2, y5, "宋体", 0, 12, mtrl_id));
				label.addLine(new Line(x3,_yy3,67,0.2,0));
				
				label.addText(new Text(x1, y6, "宋体", 0, 12, "手册号"));
				label.addText(new Text(x2, y6, "宋体", 0, 12, habk_id));
				label.addLine(new Line(x3,_yy4,67,0.2,0));
				
				label.addText(new Text(x1, y7, "宋体", 0, 12, "来料日期"));
				label.addText(new Text(x2, y7, "Arial", 0, 12, date));
				label.addLine(new Line(x3,_yy5,67,0.2,0));
				
				label.addText(new Text(x1, y8, "宋体", 0, 12, "规格"));
				label.addText(new Text(x2, y8, "Arial", 0, 12, prd_spec));
				label.addLine(new Line(x3,_yy6,67,0.2,0));
				
				label.addText(new Text(x1, y9, "宋体", 0, 12, "生产订单号"));
				label.addText(new Text(x2, y9, "Arial", 0, 12, wo_id));
				label.addLine(new Line(x3,_yy7,67,0.2,0));
				
				label.addText(new Text(x1, ya, "宋体", 0, 12, "订单数量"));
				label.addText(new Text(x2, ya, "Arial", 0, 12, woCnt));
				label.addLine(new Line(x3,_yy8,67,0.2,0));
				
				label.addText(new Text(x1, yb, "宋体", 0, 12, "本箱数量"));
				label.addText(new Text(x2, yb, "Arial", 0, 12, jaCnt[index]));
				label.addLine(new Line(x3,_yy9,67,0.2,0));
				
				label.addText(new Text(x1, yA, "宋体", 0, 12, "箱号"));
				label.addText(new Text(x2, yA, "Arial", 0, 12, (Integer.parseInt(boxRule)+index)+" / "+ totalCnt));
				label.addLine(new Line(x3,_yy0,67,0.2,0));
				
//				label.addText(new Text(x1, yC, "Arial", 0, 9, "BOXID"));
				Code code = new Code( x1, yC, 9, 0.20, ja[index]);
				try {
					label.addCode128(code);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			try {
				label.print();
			} catch (Exception e) {
				e.printStackTrace();
			}
			label.dispose();
		}
	}
	public void PrintBacth(final String batch_id){
		LabelJX label = new LabelJX(100, 100, 300);
		//label.addText(new Text(10, 18, "Arial", 0, 12, batch_id));
		Code code = new Code( 4, 3, 12, 0.3, batch_id);
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			System.out.println("before");
			label.print();
			System.out.println("after");
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	
	public void PrintJX(final String customer_id,final String mode_id,final String date,final String prd_spec,
			final String wo_id,final String woCnt,final String jsonCntAry,final String boxRule,final String totalCnt,
			final String jsonAry,final String layout_cnt) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		String[]jaCnt = null;
		int loopCnt;
		int li;
		int index;
		try {
			ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		try {
			jaCnt = mapper.readValue(jsonCntAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		System.out.println("Start");
		double len = ja.length;
		System.out.println(len);
		
		loopCnt = (int)Math.ceil(len/12);
		System.out.println(Math.ceil(len/12));
		System.out.println(len/12);
		System.out.println(loopCnt);
		
		for(li=0;li<loopCnt;li++){
			LabelJX label = new LabelJX(212, 290, 300);
			int j=0;
			int k=0;
			int lj=0;
			double step = 5.5;
			double _y = 8;
			double _yy = 15.2;
			for(lj=0;lj<12;lj++){
				index = li*12+lj;
				if( index >= ja.length){
					break;
				}
				j = lj%3;
				/**
				 * 横坐标值
				 */
				double x1 = 3.8 + 69*j;
				double x2 = 30.8 + 69*j;
				double x3 = 2 + 69*j;
				double x4 = 23 + 69*j;
				double x6 = 29.8 + 69*j;
				/**
				 * 纵坐标值
				 */
				k = lj/3;
				double y1= 9.5 + k*72 ;
				double y2 = 7.8 + k*72 ;
				double y3 = _y + 72*k + step;
				double y4 = _y + 72*k + 2*step;
				double y5 = _y + 72*k + 3*step;
				double y6 = _y + 72*k + 4*step;
				double y7 = _y + 72*k + 5*step;
				double y8 = _y + 72*k + 6*step;
				double y9 = _y + 72*k + 7*step;
				double yA = _y + 72*k + 8*step;
				double yB = 4.3  + k*72;
				double yD = 55.2 + k*72;
				/**
				 * Line的纵坐标值
				 */
				double _yy1 = _yy + k*72 ;
				double _yy2 = _yy + k*72 + step;
				double _yy3 = _yy + k*72 + 2*step;
				double _yy4 = _yy + k*72 + 3*step;
				double _yy5 = _yy + k*72 + 4*step;
				double _yy6 = _yy + k*72 + 5*step;
				double _yy7 = _yy + k*72 + 6*step;
				double _yy8 = _yy + k*72 + 7*step;
				
				label.addRectangle(new Rectangle(x3, y1, 67, 55.5, 0.2));
				label.addLine(new Line(x4,y1,44,0.2,-90));
				
				label.addText(new Text(x1, yB, "宋体", 2, 14, "方兴科技"));
//				label.addText(new Text(x5, y2, "宋体", 0, 10, "沃格光电"));
				label.addText(new Text(x6, y2, "宋体", 0, 14, "原料来料标签"));
				
				label.addText(new Text(x1, y3, "宋体", 0, 12, "客户代码"));
				label.addText(new Text(x2, y3, "Arial", 0, 12, customer_id));
				label.addLine(new Line(x3,_yy1,67,0.2,0));
				
				label.addText(new Text(x1, y4, "宋体", 0, 12, "客户型号"));
				label.addText(new Text(x2, y4, "宋体", 0, 12, mode_id+"("+layout_cnt+"模)"));
				label.addLine(new Line(x3,_yy2,67,0.2,0));
				
				label.addText(new Text(x1, y5, "宋体", 0, 12, "来料日期"));
				label.addText(new Text(x2, y5, "Arial", 0, 12, date));
				label.addLine(new Line(x3,_yy3,67,0.2,0));
				
				label.addText(new Text(x1, y6, "宋体", 0, 12, "规格"));
				label.addText(new Text(x2, y6, "Arial", 0, 12, prd_spec));
				label.addLine(new Line(x3,_yy4,67,0.2,0));
				
				label.addText(new Text(x1, y7, "宋体", 0, 12, "生产订单号"));
				label.addText(new Text(x2, y7, "Arial", 0, 12, wo_id));
				label.addLine(new Line(x3,_yy5,67,0.2,0));
				
				label.addText(new Text(x1, y8, "宋体", 0, 12, "订单数量"));
				label.addText(new Text(x2, y8, "Arial", 0, 12, woCnt));
				label.addLine(new Line(x3,_yy6,67,0.2,0));
				
				label.addText(new Text(x1, y9, "宋体", 0, 12, "本箱数量"));
				label.addText(new Text(x2, y9, "Arial", 0, 12, jaCnt[index]));
				label.addLine(new Line(x3,_yy7,67,0.2,0));
				
				label.addText(new Text(x1, yA, "宋体", 0, 12, "箱号"));
				label.addText(new Text(x2, yA, "Arial", 0, 12, (Integer.parseInt(boxRule)+index)+" / "+ totalCnt));
				label.addLine(new Line(x3,_yy8,67,0.2,0));
				
//				label.addText(new Text(x1, yC, "Arial", 0, 9, "BOXID"));
				Code code = new Code( x1, yD, 10, 0.20, ja[index]);
				try {
					label.addCode128(code);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			try {
				label.print();
			} catch (Exception e) {
				e.printStackTrace();
			}
			label.dispose();
		}
	}
	public void PrintZH(final String boxID,final String customer_name,final String modelName,final String pnlCnt,final String shtCnt,final String totalCnt,
			final String date,final String productSpec,final String lotNo,final String jsonAry,final String productCate,
			final String invalidDate, final String mtrl_lot_id) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		try {
		ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
		System.out.println("Error took place");
		e.printStackTrace();
		}
		Label label = new Label(100, 100, 300);
		label.addRectangle(new Rectangle(1, 1, 98, 97, 0.2));
		label.addText(new Text(35.8, 6.1, "宋体", 0, 16, "出货标签"));
		label.addText(new Text(65.8, 6.1, "宋体", 0, 14, "供应商编码: CX"));
		Text text = new Text(3.8, 11.8, "Arial Black", 0, 15, boxID);
		label.addText(text);
		Code code = new Code(3.8, 13, 9, 0.22, boxID);
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		label.addText(new Text(3.8, 26.1, "宋体", 0, 13, "Client Name: "
			+ customer_name));
		label.addText(new Text(3.8, 30.6, "Arial", 0, 13, "Model:  "
			+ modelName));
		label.addText(new Text(53.2, 30.6, "Arial", 0, 13, "Q'TY(Q) :"
			+ shtCnt));
		label.addText(new Text(3.8, 35.1, "Arial", 0, 13, "Date:  "
			+ date));
		label.addText(new Text(53.2, 35.1, "Arial", 0, 13, "Q'TY(S) :"
			+ totalCnt));
		label.addText(new Text(3.8, 39.6, "Arial", 0, 13, "Size:  "
			+ productSpec));
		label.addText(new Text(53.2, 39.6, "Arial", 0, 13, "Lot No:"
			+ lotNo));
		label.addText(new Text(3.8, 44.1, "Arial", 0, 13, "Invalid Date:  "
			+ invalidDate));
		label.addText(new Text(53.2, 44.1, "宋体", 0, 13, "Product Cate:"
			+ productCate));
		label.addText(new Text(3.8, 48.6, "Arial", 0, 13, "Material Lot:  "
				+ mtrl_lot_id));
		label.addText(new Text(3.8, 53.1, "Arial", 0, 13, "Order No:  "));
		
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();	
		}
		if (ja == null) {
			System.out.println("Sheet array is empty");
		} else {
			double x1 = 3.8;
			double x2 = 35.8;
			double x3 = 68.8;
			double y = 65.8;
			double step = 3.5;
			for (int i = 0; i < ja.length; i++) {
				double x = 0;
				if (i % 3 == 0) {
					x = x1;
				} else if ( i % 3 == 1){
					x = x2;
				}else{
					x = x3;
				}
				double _y =  y + (i/3)*step;
				label.addText(new Text(x, _y, "Arial", 0, 12, ja[i]));
			}
		}
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	public void PrintTM(final String boxID, final String customer_name,final String modelName,final String pnlCnt,final String shtCnt,final String totalCnt,final String date,
			final String productSpec,final String user_id, final String thickness, final String lotNo, String jsonAry,final String productCate) {
		ObjectMapper mapper = new ObjectMapper();
		String[] ja = null;
		try {
			ja = mapper.readValue(jsonAry, String[].class);
		} catch (Exception e) {
			System.out.println("Error took place");
			e.printStackTrace();
		}
		Label label = new Label(100, 100, 300);
		label.addRectangle(new Rectangle(1, 1, 98, 97, 0.2));
		label.addText(new Text(35.8, 6.1, "宋体", 0, 16, "出货标签"));
		label.addText(new Text(65.8, 6.1, "宋体", 0, 14, "供应商编码: CX"));
		Text text = new Text(3.8, 11.8, "Arial Black", 0, 15, boxID);
		label.addText(text);
		Code code = new Code(3.8, 13, 8, 0.25, boxID);
		try {
			label.addCode128(code);
		} catch (IOException e) {
			e.printStackTrace();
		}
		label.addText(new Text(3.8, 24.1, "宋体", 0, 13, "Client Name: "
				+ customer_name));
		label.addText(new Text(3.8, 28.6, "Arial", 0, 13, "Model:  "
				+ modelName));
		label.addText(new Text(56.2, 28.6, "Arial", 0, 13, "Q'TY(Q) :"
				+ shtCnt));
		label.addText(new Text(3.8, 33.1, "Arial", 0, 13, "Date:  "
				+ date));
		label.addText(new Text(56.2, 33.1, "Arial", 0, 13, "Q'TY(S) :"
				+ totalCnt));
		label.addText(new Text(3.8, 37.6, "Arial", 0, 13, "Size:  "
				+ productSpec));
		label.addText(new Text(56.2, 37.6, "Arial", 0, 13, "Lot No  :"
				+ lotNo));
		label.addText(new Text(3.8, 42.1, "Arial", 0, 13, "Pack  By:  "
				+ user_id));
		label.addText(new Text(56.2, 42.1, "Arial", 0, 13, "Thickness  :"
				+ thickness));
		label.addText(new Text(3.8, 46.6, "Arial", 0, 13, "Order No:  "));
		label.addText(new Text(56.2, 46.6, "宋体", 0, 13, "Product Cate:"
				+ productCate));
		if (ja == null) {
			System.out.println("Sheet array is empty");
		} else {
			double x1 = 3.8;
			double x2 = 35.8;
			double x3 = 68.8;
			double y = 60.3;
			double step = 3.5;
			for (int i = 0; i < ja.length; i++) {
				double x = 0;
				if (i % 3 == 0) {
					x = x1;
				} else if ( i % 3 == 1){
					x = x2;
				}else{
					x = x3;
				}
				double _y =  y + (i/3)*step;
				label.addText(new Text(x, _y, "Arial", 0, 12, ja[i]));
			}
		}
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
	//008客户标签
	public void PrintFor008(final String mdlid, final String date, final String boxid,
			                final String cnt, final String mtrl, final String grade) {
	
			LabelJX label = new LabelJX(100, 100, 300);
			label.addText(new Text(2, 4, "Arial", 0, 14, mdlid));
			label.addText(new Text(70, 4, "Arial", 0, 14, date));
			label.addText(new Text(2, 10, "Arial", 0, 14, "Label ID:"));
			label.addText(new Text(20, 10, "Arial", 0, 14, boxid));
			label.addText(new Text(61, 10, "Arial", 0, 14, "QTY:"));
			label.addText(new Text(70, 10, "Arial", 0, 14, cnt));
			label.addText(new Text(80, 20, "Arial", 0, 14, "Rev.0"));
			label.addText(new Text(66, 26, "Arial", 0, 14, "Remark:"));
			label.addText(new Text(80, 26, "Arial", 0, 14, grade));
			Code code = new Code(2, 12, 9, 0.30, boxid);
				try {
					label.addCode128nostring(code);
				} catch (IOException e) {
					e.printStackTrace();
				}
			label.addText(new Text(2, 26, "Arial", 0, 14, "P/N:"));
			label.addText(new Text(12, 26, "Arial", 0, 14, mtrl));
			Code code1 = new Code(2, 28, 9, 0.30, mtrl);
			try {
				label.addCode128nostring(code1);
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				label.print();
			} catch (Exception e) {
				e.printStackTrace();
			}
			label.dispose();
		
	}
	
	//js 二维码打印
	public void PrintJDFQR(final String str) {
		Label label = new Label(75, 20, 300);
		System.out.println("Start");
		try {
			label.addQRCode(str, 50, 50, 6);
			label.addQRCode(str, 350, 50, 6);
			label.addQRCode(str, 650, 50, 6);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		System.out.println("Start2");
		try {
			label.print();
		} catch (Exception e) {
			e.printStackTrace();
		}
		label.dispose();
	}
}
